package cn.tedu.project.oa.attendanceRule.controller;

import cn.tedu.project.oa.attendanceRule.pojo.entity.WorkingShift;
import cn.tedu.project.oa.attendanceRule.pojo.param.WorkingShiftSelectParam;
import cn.tedu.project.oa.attendanceRule.pojo.vo.WorkingShiftVO;
import cn.tedu.project.oa.attendanceRule.service.IWorkingShiftService;
import cn.tedu.project.oa.base.response.JsonResult;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/oa/attendance/workingShift")
@Api(tags = "10.班次规则")
public class WorkingShiftController {
    @Autowired
    private IWorkingShiftService workingShiftService;

    /**
     * 查询班次列表
     */
    @GetMapping("/list")
    public JsonResult list(WorkingShiftSelectParam workingShiftSelectParam)
    {
        List<WorkingShiftVO> list = workingShiftService.selectWorkingShiftList(workingShiftSelectParam);
        return JsonResult.ok(list);
    }

    /**
     * 获取班次详细信息
     */
    @GetMapping(value = "/getInfo/{id}")
    public JsonResult getInfo(@PathVariable("id") Long id)
    {
        return JsonResult.ok(workingShiftService.selectWorkingShiftById(id));
    }

    /**
     * 新增班次
     */
    @PostMapping("/add")
    public JsonResult add(WorkingShift workingShift)
    {
        log.debug("新增班次:{}", workingShift);
        return JsonResult.ok(workingShiftService.insertWorkingShift(workingShift));
    }

    /**
     * 删除班次
     */
    @PostMapping("/deleteById/{id}")
    public JsonResult remove(@PathVariable Long id) {
        return JsonResult.ok(workingShiftService.deleteWorkingShiftById(id));
    }
}
